# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html

import  pymysql
class CaifuPipeline(object):
    def __init__(self):
        self.conn = pymysql.connect("106.12.30.33","ykq","mbsb74194741","finance",charset="utf8")
        self.cursor = self.conn.cursor()

    def process_item(self, item, spider):
        sql, data = item.get_sql()
        print(sql)
        print(data)
        #try:
        self.cursor.execute(sql,data)
        self.conn.commit()
        #except:
            #self.conn.commit()

        return item

    def colse11(self):
        self.cursor.close()
        self.conn.close()

